<template>
	<view class="" v-if="phone=='18183352344'">
		
		<view class="boss">
			<view class="d_f a_i_c j_c_s_b">
				<view class="d_f">
					<image src="https://web.78keji.cn/cdimage/cdicon.png" mode="widthFix" style="width:40rpx;">
					</image>
					<view class="local">
						府河路
					</view>
				</view>
				<view class="stc">
					{{stc}}
				</view>
			</view>
			<view class="order">
				订单编号：2024042922001481442698585
			</view>
			<view class="d_f j_c_s_b" style="margin-top: 20rpx;">
				<view class="">
					入场时间
				</view>
				<view class="">
					2024-03-8 8:55
				</view>
			</view>
		</view>
		<view class="sec">
		
			<view class="d_f j_c_s_b" style="margin-top: 10rpx;">
				<view class="">
					充电费用
				</view>
				<view class="">
					10.00
				</view>
			</view>
		
		</view>
		<view class="third" v-if="stc=='进行中'" @click="zf">
			结束并支付
		</view>
		<view class="third" v-else>
			已完成
		</view>
	</view>
	<view class="box" v-else>

		<view class="d_f j_c_c " style="padding-top: 340rpx;">
			<image src="https://web.78keji.cn/cdimage/nooder.png" mode="widthFix" style="width:308rpx;">
			</image>
		</view>
		<view class="d_f j_c_c " style="padding-top: 20rpx;color: #999999;">
			暂无订单
		</view>


	</view>
</template>

<script>
	import {
	
		cdxcxOrde
	
	
	} from '../../api/index.js'
	export default {
		data() {
			return {
				phone: '',
				stc: "",
				money:""
			}
		},
		components: {

		},
		methods: {
zf(){
	
	this.money=this.money-20
	uni.setStorageSync('stc', this.stc)
	uni.setStorageSync('money', this.money)
	cdxcxOrde({user_id:my.getStorageSync({
			key:'user'
		}).data,carNum:'川A12345'}).then((resx)=>{
		my.tradePay ({
		  // 调用统一收单交易创建接口（alipay.trade.create），获得返回字段支付宝交易号 trade_no
		  tradeNO: resx.data.trade_no,
		  success: res => {
		  this.stc='已完成'
		  },
		  fail: error => {
		    console.error('调用 my.tradePay 失败: ', JSON.stringify(error));
		  },
		});
	})
}

		},
		onLoad() {
			my.getAuthCode({
				scopes: 'auth_base',
				success: (res) => {
					console.log(res)
					my.request({
						url: 'https://www.sx2b2c.com/api/rf/getAliUserid', // 请求的 URL
						method: 'POST', // POST 方法
						data: {
							code: res.authCode,
							pro_id:2014
						},
						header: {
							'Content-Type': 'application/x-www-form-urlencoded' // 设置请求头
						},
						success: (result) => {
							my.setStorageSync({
								key: 'user',
								data: result.data.data.user_id
							})
						
						},
						fail: function() {
			
						}
					})
			
				},
			});
			if (uni.getStorageSync('stc')) {
			
				this.stc = uni.getStorageSync('stc')
			}else{
				this.stc='进行中'
				uni.setStorageSync('stc', this.stc)
			}
			if (uni.getStorageSync('openid')) {

				this.phone = uni.getStorageSync('mobile')
			}
			if (uni.getStorageSync('money')) {
				this.money = uni.getStorageSync('money')
				
			}else{
				this.money = 200
				uni.setStorageSync('money', this.money)
			}

		},
		watch: {

		},
		computed: {

		}
	}
</script>

<style scoped>
	.box {
		position: relative;
		min-height: 100vh;
		min-width: 100%;
		background-color: #F5F5F5;
	}

	.boss {
		background-image: url('https://web.78keji.cn/cdimage/bgsx.png');
		background-size: 100% 100%;
		height: 180rpx;
		padding: 24rpx 24rpx 0 24rpx;
		margin: 24rpx 24rpx 0 24rpx;

	}

	.local {

		font-weight: 800;
		font-size: 32rpx;
		color: #1A1A1A;
		margin-left: 10rpx;

	}

	.stc {
		font-size: 28rpx;
		color: #167BFF;
	}

	.order {


		font-size: 20rpx;
		color: #0E0E0E;
		margin-top: 20rpx;

	}

	.sec {
		background-color: white;

		margin: 0 24rpx 0 24rpx;
		padding: 0 24rpx 24rpx 24rpx;
	}

	.third {
		background-color: #167BFF;
		height: 80rpx;
		margin: 0 24rpx 0 24rpx;

		color: white;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>